<template>
  <a-checkbox
    v-model:checked="check"
    :disabled="disabled"
    :indeterminate="indeterminate"
    :autofocus="autofocus"
    :value="value"
  >
    <slot />
  </a-checkbox>
</template>
<script>
import { defineComponent, computed } from 'vue'
import { Checkbox } from 'ant-design-vue'
export default defineComponent({
  name: 'ZCheckbox',
  components: {
    ACheckbox: Checkbox
  },
  props: {
    autofocus: {
      type: Boolean,
      default: false
    },
    disabled: {
      type: Boolean,
      default: false
    },
    indeterminate: {
      type: Boolean,
      default: false
    },
    checked: {
      type: Boolean,
      default: undefined
    },
    value: {
      type: [String, Boolean, Number],
      default: undefined
    }
  },
  setup(props, _ref) {
    const check = computed({
      get() {
        return props.checked
      },
      set(val) {
        _ref.emit('update:checked', val)
      }
    })
    return {
      check
    }
  }
})
</script>
